package com.zyh.homework.test08;

import com.zyh.homework.test08.domain.User;

import java.util.Scanner;

public class Test8 {
    public static final User[] users = new User[3];
    static {
        users[0]=new User("zyh","123");
        users[1]=new User("jyh","222");
        users[2]=new User("mjd","333");
    }
    public static final Scanner INPUT=new Scanner(System.in);

    public static void main(String[] args) {
        System.out.println("请输入用户名：");
        String userName = INPUT.next();
        System.out.println("请输入密码：");
        String userPassword = INPUT.next();
        //假设不存在
        boolean flag=false;
        for (int i = 0; i < users.length; i++) {
            if (users[i].getName().equals(userName)&&users[i].getPassword().equals(userPassword)){
                flag=true;
                break;
            }
        }
        if (flag){
            System.out.println("登录结果：登陆成功");
        }
        else {
            System.out.println("登录结果：账号或密码错误");
        }
    }
}
